import 'package:finance_app/src/entities/suggest_date_entity.dart';

suggestDateEntityFromJson(SuggestDateEntity data, Map<String, dynamic> json) {
	if (json['financial_year_date'] != null) {
		data.financialYearDate = StartEndDateEntity().fromJson(json['financial_year_date']);
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['type_date'] != null) {
		data.typeDate = json['type_date'].toString();
	}
	if (json['system_date'] != null) {
		data.systemDate = json['system_date'].toString();
	}
	return data;
}

Map<String, dynamic> suggestDateEntityToJson(SuggestDateEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['financial_year_date'] = entity.financialYearDate?.toJson();
	data['type'] = entity.type;
	data['type_date'] = entity.typeDate;
	data['system_date'] = entity.systemDate;
	return data;
}

suggestDateListEntityFromJson(SuggestDateListEntity data, Map<String, dynamic> json) {
	if (json['financial_year_date'] != null) {
		data.financialYearDate = StartEndDateEntity().fromJson(json['financial_year_date']);
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['type_date'] != null) {
		data.typeDate = (json['type_date'] as List).map((v) => StartEndDateEntity().fromJson(v)).toList();
	}
	if (json['system_date'] != null) {
		data.systemDate = json['system_date'].toString();
	}
	return data;
}

Map<String, dynamic> suggestDateListEntityToJson(SuggestDateListEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['financial_year_date'] = entity.financialYearDate?.toJson();
	data['type'] = entity.type;
	data['type_date'] =  entity.typeDate?.map((v) => v.toJson())?.toList();
	data['system_date'] = entity.systemDate;
	return data;
}

startEndDateEntityFromJson(StartEndDateEntity data, Map<String, dynamic> json) {
	if (json['start'] != null) {
		data.start = json['start'].toString();
	}
	if (json['end'] != null) {
		data.end = json['end'].toString();
	}
	return data;
}

Map<String, dynamic> startEndDateEntityToJson(StartEndDateEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['start'] = entity.start;
	data['end'] = entity.end;
	return data;
}